package cn.bitkit.tools.data;

import lombok.AllArgsConstructor;

import java.util.regex.Pattern;

@AllArgsConstructor
public enum CheckType {
    N(Pattern.compile("^[0-9]*")),
    AN(Pattern.compile("^[0-9a-zA-Z]*")),
    ANS(Pattern.compile("^[\\x21-\\x7E]+$")),
    DIGIT(Pattern.compile("^(0|[1-9]\\d+)(\\.\\d+)?$")),
    WORD(Pattern.compile("^[a-zA-Z]*$")),
    HEX(Pattern.compile("^[a-fA-F0-9]*$")),
    PHONE(Pattern.compile("^1[3-9]\\d{9}$")),
    TELEPHONE(Pattern.compile("^(1[3-9]\\d{9})|(0\\d{2,3}-\\d{7,8})$")),
    EMAIL(Pattern.compile("^([\\da-zA-Z\\\\.-_])+@([\\da-z-]+)+(\\.[\\da-z-]+)*(\\.[a-z]{2,8})$")),
    IP(Pattern.compile("^((2(5[0-5]|[0-4]\\d))|[0-1]?\\d{1,2})(\\.((2(5[0-5]|[0-4]\\d))|[0-1]?\\d{1,2})){3}$")),
    IPV6(Pattern.compile("^[a-fA-F0-9:]*$")),
    CHINESE(Pattern.compile("^[\u4e00-\u9fa5]*$")),
    ;
    private final Pattern pattern;

    public boolean check(String data){
        return pattern.matcher(data).matches();
    }
}
